package com.lbs.tdrive;

import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.util.EntityUtils;

import com.lbs.tdrive.comon.HttpASync;
import com.lbs.tdrive.comon.HttpASync.OnRequest;
import com.lbs.tdrive.constant.AppConstant;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


public class RegisterActivity extends Activity implements OnClickListener {

	private Button cancel;
	private Button submit;
	private EditText fname;
	private EditText lname;
    private EditText email;
	private EditText confirm_id;
	private EditText password;
	private EditText confirm_pass;
	private EditText phone;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.register);
		cancel=(Button)findViewById(R.id.button1);
		submit=(Button)findViewById(R.id.button2);
		fname=(EditText)findViewById(R.id.editText1);
		lname=(EditText)findViewById(R.id.editText2);
		email=(EditText)findViewById(R.id.editText3);
		confirm_id=(EditText)findViewById(R.id.editText4);
		password=(EditText)findViewById(R.id.editText5);
		confirm_pass=(EditText)findViewById(R.id.editText6);
		phone=(EditText)findViewById(R.id.editText7);
		cancel.setOnClickListener(this);
		submit.setOnClickListener(this);
	}
	
	public void onClick(View v){
		if (v.getId()==R.id.button1){
			finish();
		}
	    else if (v.getId()==R.id.button2){
	        String f_name=fname.getText().toString();
	        String l_name=lname.getText().toString();
	        String email_id=email.getText().toString();
	        String c_id=confirm_id.getText().toString();
	        String pass=password.getText().toString();
	        String c_pass=confirm_pass.getText().toString();
	        String no=phone.getText().toString();
	        if(pass.equals(c_pass)==false){
	        	Toast.makeText(RegisterActivity.this,"Password does not match!!!", Toast.LENGTH_SHORT).show();
	        	 password.setText("");
	   	         confirm_pass.setText("");        
	        }
	        else if(email_id.equals(c_id)==false){
	        	Toast.makeText(RegisterActivity.this,"E-mail id does not match!!!", Toast.LENGTH_SHORT).show();
	            email.setText("");
		        confirm_id.setText("");
	        }
		    else if(f_name.equals("")||l_name.equals("")||email_id.equals("")||c_id.equals("")||pass.equals("")||c_pass.equals("")||no.equals(""))
			     Toast.makeText(RegisterActivity.this,"Enter data in all fields!!!", Toast.LENGTH_SHORT).show();	
		    else
	        	Toast.makeText(RegisterActivity.this,"Registration Successful!!!", Toast.LENGTH_SHORT).show();
	      	
		}	

	}
	
	
	
}
